home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
program
/
16
/
vdi.fth
< prev
next >
Wrap
Text File
|
1985-11-19
|
4KB
|
151 lines
\ GEM VDI calling routines
\
\ This was written by Jesse Taylor.
\ These may change or disappear in future versions (presumably to be
\ replaced by something better).
decimal
\ these are the parameter input and output array's to the vdi
create contrl-buf 26 allot
create intin-buf 258 allot
create ptsin-buf 512 allot
create intout-buf 258 allot
create ptsout-buf 258 allot
\ this is the parameter block that is passed to vdi in register d1
create vdi-block contrl-buf , intin-buf , ptsin-buf ,
intout-buf , ptsout-buf , 0 , 0 ,
create aes-block contrl-buf , intin-buf , ptsin-buf ,
intout-buf , ptsout-buf , 0 , 0 ,
\ these are important variables. take my word for it
variable vhandle
\ these are some convenient routines for getting at the parameter array's
: contrl[] ( n -- adr ) ( returns address of array element )
contrl-buf swap wa+
;
: intin[] ( n -- adr ) ( returns address of array element )
intin-buf swap wa+
;
: ptsin[] ( n -- adr ) ( returns address of array element )
ptsin-buf swap wa+
;
: intout[] ( n -- adr ) ( returns address of array element )
intout-buf swap wa+
;
: ptsout[] ( n -- adr ) ( returns address of array element )
ptsout-buf swap wa+
;
\ these are some higher level parameter array setting routines
: !pba-intin ( adr -- ) ( set pba to point too new address )
vdi-block 4 + !
;
: !pba-ptsin ( adr -- ) ( set pba to point too new address )
vdi-block 8 + !
;
: !pba-intout ( adr -- ) ( set pba to point too new address )
vdi-block 12 + !
;
: !pba-ptsout ( adr -- ) ( set pba to point too new address )
vdi-block 16 + !
;
: contrl! ( n1 n2 -- ) ( store n1 into n2 item in the contrl[] array )
contrl[] w!
;
: contrl@ ( n1 -- n2 ) ( fetch n1 item from the contrl[] array )
contrl[] w@
;
: set-op ( n -- ) ( set contrl[0] which holds the current vdi function # )
contrl-buf w!
;
: ptsin! ( x y n -- ) ( store x y coordinate into n'th item in ptsin[] )
tuck 1+ ptsin[] w! ptsin[] w!
;
: ptsout@ ( n -- x y ) ( get x y coordinate from n'th item in ptsout[] )
dup ptsout[] w@ swap 1+ ptsout[] w@
;
: intin! ( n1 n2 -- ) ( store n1 into the n2 item in the intin array )
intin[] w!
;
: intout@ ( n1 -- n2 ) ( fetch n2 from the n1 item in the intout array )
intout[] w@
;
: #ptsin! ( n -- ) ( store number into contrl[1] )
1 contrl!
;
: #intin! ( n -- ) ( store number into contrl[3] )
3 contrl!
;
: #ptsinoff ( -- ) ( zero the intin value in the contrl array )
0 #ptsin!
;
: #intinoff ( -- ) ( zero the intin value in the contrl array )
0 #intin!
;
: #pt-intinoff ( -- ) ( turn both intin and ptsin values off )
#intinoff #ptsinoff
;
: #dev! ( n -- ) ( set the device pointer in the contrl array )
6 contrl!
;
: set-device ( -- ) ( store the current vdi device handle into contrl[6] )
vhandle @ #dev!
;
\ this is the vdi calling routine
code callvdi ( -- ) ( call vdi from forth )
a3 sp -) lmove a4 sp -) lmove a5 sp -) lmove a6 sp -) lmove
vdi-block l# d1 lmove
decimal 115 # d0 wmove decimal
2 trap
sp )+ a6 lmove sp )+ a5 lmove sp )+ a4 lmove sp )+ a3 lmove
c;
code callaes ( -- ) ( call aes from forth )
a3 sp -) lmove a4 sp -) lmove a5 sp -) lmove a6 sp -) lmove
aes-block l# d1 lmove
hex 0c8 # decimal d0 wmove
2 trap
sp )+ a6 lmove sp )+ a5 lmove sp )+ a4 lmove sp )+ a3 lmove
c;
decimal
: appl_init ( -- id ) ( initializes you gem application )
10 0 contrl[] w! 1 2 contrl[] w! 0 1 contrl[] w! 0 3 contrl[] w!
callaes 0 intout@
;
: open-virt
100 set-op
0 1 contrl!
11 3 contrl!
1 6 contrl!
1 0 intin!
9 1
do 1 i intin! loop
2 10 intin!
callvdi
6 contrl[] w@ vhandle !
;
: close-virt
101 set-op
0 1 contrl!
0 3 contrl!
set-device
callvdi
;
ff 1 expected-sector ! #naks off #control-z's off
;
variable last-char
: timed-in ( -- ch